package com.daimler.itffo.uvs.kern;

import java.io.File;
import java.io.FileOutputStream;

public class SQLWriter {
	public static final String FILENAME_DEQT_EU = new String("deqt.sql");
	public static final String FILENAME_DEQT_UX = new String("deqt_ux.sql");
	public static final String FILENAME_DEQT_EU_DOUBLE = new String(
			"deqt_double_entries.sql");
	public static final String FILENAME_DEQT_UX_DOUBLE = new String(
			"deqt_double_entries_ux.sql");

	public static final String FILENAME_TYKZ_EU = new String("tykz.sql");
	public static final String FILENAME_B158_EU = new String("b158.sql");
	public static final String FILENAME_B044_EU = new String("b044.sql");
	public static final String FILENAME_B157_EU = new String("b157.sql");
	public static final String FILENAME_B171_EU = new String("b171.sql");
	public static final String FILENAME_B158_UX = new String("b158_ux.sql");
	public static final String FILENAME_DTCV_EU = new String("dtcv.sql");
	public static final String FILENAME_DGCV_EU = new String("dgcv.sql");
	public static final String FILENAME_B035_EU = new String("b035.sql");
	public static final String FILENAME_DTCV_UX = new String("dtcv_ux.sql");
	public static final String FILENAME_B175 = new String("b175.sql");
	public static final String FILENAME_B172_EU = new String("b172.sql");
	public static final String FILENAME_B172_UX = new String("b172_ux.sql");
	

	private static final String ENCODING_LATIN1 = new String("ISO-8859-1");

	public static final String NEWLINE = new String("\r\n");

	FileOutputStream out;

	public void openFile(String filename) {
		try {
			File file = new File(filename);
			// System.out.println(file.getAbsoluteFile());
			// System.out.println(file.canWrite());
			out = new FileOutputStream(file, false);
			// System.out.println(out.getFD().toString());
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}

	}

	public void write(SQLStatment sqlStatment) {
		try {
			out.write(sqlStatment.getSqlStatment().getBytes(ENCODING_LATIN1));
			out.write(NEWLINE.getBytes(ENCODING_LATIN1));
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public void close() {
		try {
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);

		}
	}

}
